package com.example.forumadminbackend.controller;

import com.example.forumadminbackend.service.WordService;
import com.example.forumadminbackend.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/api")
@Tag(name = "公开接口")
public class PublicApiController {
    @Autowired
    private WordService wordService;

    @GetMapping("/words")
    @Operation(summary = "公开查询所有违禁词", description = "所有用户均可访问，无需登录")
    public ResponseEntity<Result<List<String>>> getAllWordsPublic() {
        try {
            return ResponseEntity.ok(Result.success(wordService.getAllWords()));
        } catch (Exception e) {
            return ResponseEntity.status(400).body(Result.fail("获取违禁词失败"));
        }
    }
} 